package tmsdkobf; import android.content.Context; import android.net.DhcpInfo; import android.net.wifi.ScanResult; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; import com.miui.guardprovider.engine.mi.antivirus.NetworkApiHelper; import com.qq.taf.jce.JceStruct; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Matcher; import java.util.regex.Pattern; import tmsdk.bg.creator.BaseManagerB; import tmsdk.bg.module.wifidetect.IWifiBatchDetectListener; import tmsdk.bg.module.wifidetect.IWifiDetectListener; import tmsdk.bg.module.wifidetect.WifiDetectManager; public class p9 extends BaseManagerB { /* renamed from: b reason: collision with root package name */ private Context f1259b; private WifiManager c; private Handler d; /* access modifiers changed from: package-private */ public class a extends Handler { a(p9 p9Var, Looper looper) { super(looper); } public void handleMessage(Message message) { IWifiBatchDetectListener iWifiBatchDetectListener; int i = message.what; if (i == 4097) { sb.a("WifiDetectManager", (Object) ("onResult-CLOUND_CHECK:[" + message.arg1 + "]")); IWifiDetectListener iWifiDetectListener = (IWifiDetectListener) message.obj; if (iWifiDetectListener != null) { iWifiDetectListener.onResult(message.arg1); } } else if (i == 4098 && (iWifiBatchDetectListener = (IWifiBatchDetectListener) message.obj) != null) { iWifiBatchDetectListener.onResult(message.getData().getIntArray("RET")); } } } /* access modifiers changed from: package-private */ public class b implements v3 { /* renamed from: a reason: collision with root package name */ final /* synthetic */ IWifiDetectListener f1260a; b(IWifiDetectListener iWifiDetectListener) { this.f1260a = iWifiDetectListener; } @Override // tmsdkobf.v3 public void onFinish(int i, int i2, int i3, int i4, JceStruct jceStruct) { int i5; sb.a("WifiDetectManager", (Object) ("onFinish retCode:[" + i3 + "]" + "dataRetCode:[" + i4 + "]")); sb.b("WifiDetectManager", "[WifiDetectManager] disconnect for detectDnsAndPhishing"); Message obtainMessage = p9.this.d.obtainMessage(4097); if (i3 != 0 || jceStruct == null || !(jceStruct instanceof c1)) { sb.a("WifiDetectManager", (Object) "[CLOUND_CHECK_NETWORK_ERROR]"); i5 = 16; } else { c1 c1Var = (c1) jceStruct; int i6 = c1Var.f1029b; if (i6 == 2) { sb.a("WifiDetectManager", (Object) "[CLOUND_CHECK_DNS_FAKE]ESafeType.EST_DnsException"); y9.c(1320068, "CLOUND_DNS_FAKE"); i5 = 18; } else if (i6 == 3) { sb.a("WifiDetectManager", (Object) "[CLOUND_CHECK_PHISHING_FAKE]ESafeType.EST_Phishing"); y9.c(1320068, "CLOUND_PHISHING_FAKE"); i5 = 19; } else if (i6 == 4) { sb.a("WifiDetectManager", (Object) "[CLOUND_CHECK_PASSWORD_LEAK_RISK]ESafeType.EST_PasswordLeak"); y9.c(1320068, "CLOUND_PASSWORD_LEAK_RISK"); i5 = 20; } else { sb.a("WifiDetectManager", (Object) ("[CLOUND_CHECK_NO_FAKE]safeType:[" + c1Var.f1029b + "]")); y9.c(1320068, "CLOUND_NO_FAKE"); i5 = 17; } } obtainMessage.arg1 = i5; obtainMessage.obj = this.f1260a; p9.this.d.sendMessage(obtainMessage); } } /* access modifiers changed from: package-private */ public class c implements v3 { /* renamed from: a reason: collision with root package name */ final /* synthetic */ int f1262a; /* renamed from: b reason: collision with root package name */ final /* synthetic */ z0 f1263b; final /* synthetic */ int[] c; final /* synthetic */ Message d; c(int i, z0 z0Var, int[] iArr, Message message) { this.f1262a = i; this.f1263b = z0Var; this.c = iArr; this.d = message; } @Override // tmsdkobf.v3 public void onFinish(int i, int i2, int i3, int i4, JceStruct jceStruct) { sb.a("WifiDetectManager", (Object) ("onFinish Cmd_CSBatchGetCloudCheck retCode:[" + i3 + "]" + "dataRetCode:[" + i4 + "]")); sb.b("WifiDetectManager", "[WifiDetectManager] disconnect for detectPhishingBatch"); boolean z = true; if (i3 == 0 && jceStruct != null && (jceStruct instanceof b1)) { b1 b1Var = (b1) jceStruct; ArrayList<Integer> arrayList = b1Var.f1015b; if (arrayList == null || arrayList.size() != this.f1262a) { z = false; } else { for (int i5 = 0; i5 < this.f1262a; i5++) { sb.c("WifiDetectManager", (Object) ("[" + this.f1263b.f1459b.get(i5).f1045b + "][" + b1Var.f1015b.get(i5).intValue() + "]")); if (b1Var.f1015b.get(i5).intValue() == 3) { this.c[i5] = 19; } else if (b1Var.f1015b.get(i5).intValue() == 4) { this.c[i5] = 20; } else { this.c[i5] = 17; } } } } if (z) { Bundle bundle = new Bundle(); bundle.putIntArray("RET", this.c); this.d.setData(bundle); } p9.this.d.sendMessage(this.d); } } public p9() { new AtomicBoolean(false); } /* JADX WARNING: Missing exception handler attribute for start block: B:10:0x001e */ private String a(InputStream inputStream) { BufferedReader bufferedReader; StringBuilder sb; bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); sb = new StringBuilder(); while (true) { try { String readLine = bufferedReader.readLine(); if (readLine != null) { sb.append(readLine); } } catch (IOException unknown) { bufferedReader.close(); return sb.toString(); } catch (Throwable th) { try { bufferedReader.close(); } catch (IOException unused) { } throw th; } try { bufferedReader.close(); } catch (IOException unused2) { } return sb.toString(); } } /* JADX WARNING: Code restructure failed: missing block: B:23:0x00c3, code lost: if (r4 != null) goto L_0x00c9; */ /* JADX WARNING: Code restructure failed: missing block: B:26:0x00c7, code lost: if (0 != 0) goto L_0x00c9; */ /* JADX WARNING: Code restructure failed: missing block: B:29:?, code lost: r4.close(); */ private String a(String str, HttpURLConnection httpURLConnection) { String str2; InputStream inputStream = null; try { String host = new URL(str).getHost(); String host2 = httpURLConnection.getURL().getHost(); sb.a("WifiDetectManager", (Object) ("urlHost:[" + host + "]httpHost:[" + host2 + "]")); str2 = !host.equals(host2) ? httpURLConnection.getURL().toExternalForm() : null; if (str2 == null) { try { if (httpURLConnection.getHeaderField("Location") != null) { str2 = httpURLConnection.getHeaderField("Location"); sb.a("WifiDetectManager", (Object) ("111location:[" + str2 + "]")); } } catch (Throwable unused) { } } if (str2 == null && httpURLConnection.getHeaderField("Refresh") != null) { String[] split = httpURLConnection.getHeaderField("Refresh").split(";"); if (split.length == 2) { str2 = split[1].trim(); } sb.a("WifiDetectManager", (Object) ("222location:[" + str2 + "]")); } if (str2 == null) { inputStream = httpURLConnection.getInputStream(); if (inputStream != null) { str2 = b(inputStream); } sb.a("WifiDetectManager", (Object) ("333location:[" + str2 + "]")); } } catch (Throwable unused2) { str2 = null; } return str2; } private String b(InputStream inputStream) { String a2 = a(inputStream); sb.a("WifiDetectManager", (Object) ("parsePage-pageContent:[" + a2 + "]")); String[] strArr = {"http-equiv\\s*=\\s*[\"']*refresh[\"']*\\s*content\\s*=\\s*[\"']*[^;]*;\\s*url\\s*=\\s*[\"']*([^\"'\\s>]+)", "[^\\w](?:location.href\\s*=|location\\s*=|location.replace\\s*\\()\\s*[\"']*([^\"'>]+)", "<NextURL>([^<]+)", "\\s+action\\s*=\\s*[\"']*([^\"'>]+)[\"'>\\s]*.*submit", "<LoginURL>([^<]+)"}; int length = strArr.length; String str = null; for (int i = 0; i < length && str == null; i++) { Matcher matcher = Pattern.compile(strArr[i], 2).matcher(a2); while (matcher.find() && str == null) { str = matcher.group(matcher.groupCount()); if (str != null && !str.trim().toLowerCase().startsWith("http")) { str = null; } } } sb.a("WifiDetectManager", (Object) ("parsePage-location:[" + str + "]")); return str; } public synchronized int detectARPNoRoot(long j) { int i; sb.a("WifiDetectManager", (Object) "[Beg]detectARPNoRoot"); y9.f(29978); i = 261; try { i = new q9().a(this.c.getConnectionInfo().getBSSID(), j); } catch (Throwable th) { sb.a("WifiDetectManager", (Object) ("no root detect error:[" + th + "]")); } y9.c(1320068, i == 262 ? "NOROOT_ARP_FAKE" : "NOROOT_ARP_OK"); sb.a("WifiDetectManager", (Object) ("[End]detectARPNoRoot-nRetState:[" + i + "]")); return i; } public int detectDnsAndPhishing(IWifiDetectListener iWifiDetectListener, long j) { String str; y9.f(29979); if (vb.b(this.f1259b)) { sb.a("WifiDetectManager", (Object) ("[Beg]detectDnsAndPhishinglistener:[" + iWifiDetectListener + "]")); WifiInfo connectionInfo = ((WifiManager) this.f1259b.getSystemService("wifi")).getConnectionInfo(); if (connectionInfo == null) { return -2; } String ssid = connectionInfo.getSSID(); String bssid = connectionInfo.getBSSID(); sb.a("WifiDetectManager", (Object) ("ssid:[" + ssid + "]bssid:[" + bssid + "]")); if (bc.b(ssid) || bc.b(bssid)) { sb.a("WifiDetectManager", (Object) "[End]detectDnsAndPhishing 参数不对"); return -3; } String str2 = null; try { DhcpInfo dhcpInfo = this.c.getDhcpInfo(); if (dhcpInfo != null) { str = dc.a((long) dhcpInfo.dns1); try { str2 = dc.a((long) dhcpInfo.dns2); } catch (Exception unused) { } sb.a("WifiDetectManager", (Object) ("dns1:[" + str + "]dns2:[" + str2 + "]")); a1 a1Var = new a1(); a1Var.f1004b = new d1(); d1 d1Var = a1Var.f1004b; d1Var.f1045b = ssid; d1Var.c = bssid; a1Var.c = new ArrayList<>(); if (str != null && str.length() > 0) { a1Var.c.add(str); } if (str2 != null && str2.length() > 0) { a1Var.c.add(str2); } x5 f = b5.f(); sb.a("WifiDetectManager", (Object) ("[GUID] " + f.b())); sb.a("WifiDetectManager", "[WifiDetectManager] connect for detectDnsAndPhishing"); f.a(794, a1Var, new c1(), 0, new b(iWifiDetectListener), j); w9.b(); sb.a("WifiDetectManager", (Object) ("[End]detectDnsAndPhishing-ssid:[" + ssid + "]bssid:[" + bssid + "]")); return 0; } } catch (Exception unused2) { } str = null; sb.a("WifiDetectManager", (Object) ("dns1:[" + str + "]dns2:[" + str2 + "]")); a1 a1Var2 = new a1(); a1Var2.f1004b = new d1(); d1 d1Var2 = a1Var2.f1004b; d1Var2.f1045b = ssid; d1Var2.c = bssid; a1Var2.c = new ArrayList<>(); a1Var2.c.add(str); a1Var2.c.add(str2); x5 f2 = b5.f(); sb.a("WifiDetectManager", (Object) ("[GUID] " + f2.b())); sb.a("WifiDetectManager", "[WifiDetectManager] connect for detectDnsAndPhishing"); f2.a(794, a1Var2, new c1(), 0, new b(iWifiDetectListener), j); w9.b(); sb.a("WifiDetectManager", (Object) ("[End]detectDnsAndPhishing-ssid:[" + ssid + "]bssid:[" + bssid + "]")); return 0; } sb.a("WifiDetectManager", (Object) "[WifiConnected false]"); iWifiDetectListener.onResult(-1); return -1; } /* JADX WARNING: Code restructure failed: missing block: B:24:0x00bb, code lost: if (r9 != null) goto L_0x00db; */ /* JADX WARNING: Code restructure failed: missing block: B:32:0x00de, code lost: tmsdkobf.sb.a("WifiDetectManager", (java.lang.Object) ("[End]detectNetworkState-nRet:[" + r5 + "]")); */ /* JADX WARNING: Code restructure failed: missing block: B:33:0x00f5, code lost: return r5; */ public int detectNetworkState() { HttpURLConnection httpURLConnection; Object th; int i; y9.f(29981); sb.a("WifiDetectManager", (Object) "[Beg]detectNetworkState-urlApprove:[http://tools.3g.qq.com/wifi/cw.html]customHeader:[Meri]"); int i2 = 2; try { long currentTimeMillis = System.currentTimeMillis(); sb.a("WifiDetectManager", (Object) "openConnection"); httpURLConnection = (HttpURLConnection) new URL("http://tools.3g.qq.com/wifi/cw.html").openConnection(); try { if (zb.a() < 8) { System.setProperty("http.keepAlive", "false"); } httpURLConnection.setUseCaches(false); httpURLConnection.setRequestProperty("Pragma", "no-cache"); httpURLConnection.setRequestProperty("Cache-Control", "no-cache"); httpURLConnection.setInstanceFollowRedirects(false); httpURLConnection.setRequestMethod(NetworkApiHelper.REQUEST_METHOD_GET); httpURLConnection.setReadTimeout(30000); int responseCode = httpURLConnection.getResponseCode(); sb.a("WifiDetectManager", (Object) ("getResponseCode:[" + responseCode + "]timeMillis:[" + (System.currentTimeMillis() - currentTimeMillis) + "]")); if (responseCode == 200 || (responseCode >= 301 && responseCode <= 305)) { String headerField = httpURLConnection.getHeaderField("Meri"); sb.a("WifiDetectManager", (Object) ("customHeader: " + headerField)); if (headerField == null || headerField.compareToIgnoreCase("Meri") != 0) { String a2 = a("http://tools.3g.qq.com/wifi/cw.html", httpURLConnection); if (!(a2 == null || a2.compareToIgnoreCase("http://miwifi.com/diagnosis/index.html") == 0)) { i = 3; } } else { i = 1; } i2 = i; } } catch (Throwable th2) { th = th2; try { sb.a("WifiDetectManager", (Object) ("Throwable:[" + th + "]")); } finally { if (httpURLConnection != null) { httpURLConnection.disconnect(); } } } } catch (Throwable th3) { th = th3; httpURLConnection = null; sb.a("WifiDetectManager", (Object) ("Throwable:[" + th + "]")); } } public int detectPhishingBatch(List<String> list, List<String> list2, IWifiBatchDetectListener iWifiBatchDetectListener, long j) { y9.f(29979); Message obtainMessage = this.d.obtainMessage(4098); obtainMessage.obj = iWifiBatchDetectListener; if (vb.d()) { sb.a("WifiDetectManager", (Object) ("detectPhishingBatchlistener:[" + iWifiBatchDetectListener + "]")); z0 z0Var = new z0(); z0Var.f1459b = new ArrayList<>(); int size = list.size(); int[] iArr = new int[size]; for (int i = 0; i < size; i++) { d1 d1Var = new d1(); d1Var.f1045b = list.get(i); d1Var.c = list2.get(i); z0Var.f1459b.add(d1Var); iArr[i] = 16; } z0Var.i = xb.e(); x5 f = b5.f(); sb.c("WifiDetectManager", (Object) ("[GUID] " + f.b())); sb.a("WifiDetectManager", "[WifiDetectManager] connect for detectPhishingBatch"); f.a(800, z0Var, new b1(), 0, new c(size, z0Var, iArr, obtainMessage), j); return 0; } sb.a("WifiDetectManager", (Object) "[isNetworkConnected false]"); this.d.sendMessage(obtainMessage); return -1; } /* JADX WARNING: Code restructure failed: missing block: B:18:0x0089, code lost: if (r7 != null) goto L_0x00ab; */ /* JADX WARNING: Code restructure failed: missing block: B:26:0x00ae, code lost: tmsdkobf.sb.a("WifiDetectManager", (java.lang.Object) ("[End]detectSSLStrip-nRetState:[" + r6 + "]time(millis) elapsed:[" + (java.lang.System.currentTimeMillis() - r2) + "]")); */ /* JADX WARNING: Code restructure failed: missing block: B:27:0x00d5, code lost: if (r6 != 272) goto L_0x00da; */ /* JADX WARNING: Code restructure failed: missing block: B:28:0x00d7, code lost: r1 = "SSLSTRIP_ATTACK"; */ /* JADX WARNING: Code restructure failed: missing block: B:29:0x00da, code lost: r1 = "SSLSTRIP_OK"; */ /* JADX WARNING: Code restructure failed: missing block: B:30:0x00dc, code lost: tmsdkobf.y9.c(1320068, r1); */ /* JADX WARNING: Code restructure failed: missing block: B:31:0x00df, code lost: return r6; */ public int detectSSLStrip() { HttpURLConnection httpURLConnection; Object th; sb.a("WifiDetectManager", (Object) "[Beg]detectSSLStrip"); y9.f(1320084); long currentTimeMillis = System.currentTimeMillis(); if (!vb.b(this.f1259b)) { sb.a("WifiDetectManager", (Object) "[End]detectSSLStrip-SSLSTRIP_WIFI_NOTAVILABLE"); return WifiDetectManager.SSLSTRIP_WIFI_NOTAVILABLE; } int i = WifiDetectManager.SSLSTRIP_OK; try { httpURLConnection = (HttpURLConnection) new URL("http://tools.3g.qq.com/j/sslstrip").openConnection(); try { httpURLConnection.setConnectTimeout(com.xiaomi.onetrack.g.b.f820a); httpURLConnection.setReadTimeout(com.xiaomi.onetrack.g.b.f820a); httpURLConnection.setInstanceFollowRedirects(false); int responseCode = httpURLConnection.getResponseCode(); List<String> list = httpURLConnection.getHeaderFields().get("Location"); if (list.size() == 1) { String lowerCase = list.get(0).toLowerCase(); sb.c("WifiDetectManager", (Object) ("url: " + lowerCase)); if (lowerCase.startsWith("http://m.qq.com")) { } } else if (responseCode == 200) { sb.c("WifiDetectManager", (Object) "StatusCode 200"); } i = 272; } catch (Throwable th2) { th = th2; try { sb.b("WifiDetectManager", (Object) ("t:[" + th + "]")); } finally { if (httpURLConnection != null) { httpURLConnection.disconnect(); } } } } catch (Throwable th3) { httpURLConnection = null; th = th3; sb.b("WifiDetectManager", (Object) ("t:[" + th + "]")); } } public int detectSecurity(ScanResult scanResult) { String str; y9.f(29980); sb.a("WifiDetectManager", (Object) ("[Beg]detectSecurity-AP:[" + scanResult + "]")); if (scanResult == null || (str = scanResult.capabilities) == null) { return -2; } int i = str.contains("WEP") ? 257 : scanResult.capabilities.contains("PSK") ? 258 : scanResult.capabilities.contains("EAP") ? 259 : scanResult.capabilities.contains("SAE") ? 260 : 256; sb.a("WifiDetectManager", (Object) ("[End]detectSecurity-Ret:[" + i + "]")); return i; } @Override // tmsdkobf.r4 public int getSingletonType() { return 2; } @Override // tmsdkobf.r4 public void onCreate(Context context) { sb.a("WifiDetectManager", (Object) ("OnCreate-context:[" + context + "]")); this.f1259b = context; this.c = (WifiManager) context.getSystemService("wifi"); this.d = new a(this, Looper.getMainLooper()); } }